<footer>
    <div class="mail container">
        <div class="mailImg">
            <img src="./images/mail.png" alt="">
        </div>
        <div class="mailInfo">
            订阅我们的新资讯、新商品 与 优惠信息
        </div>
        <form action="">
            <input type="email" placeholder="您的邮箱" id="subEmail" required>
            <input type="submit" value="提交！" id="subscribe">
        </form>
    </div>
    <div class="copyright">
        <div class="inner container">
            &copy;2020 LingGuang Griphics Shop.
        </div>
    </div>
</footer>
<script src="./js/jquery-3.5.1.js"></script>
<script>
    let reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
    $('#subscribe').click(function (){
        if($('#subEmail').val() === ''){
            alert('请输入完整邮箱')
        }else if(!reg.test($('#subEmail').val())){
            alert('请输入正确的邮箱')
        }else{
            $.post('connect.php',{
                type: 'newSub',
                email: $('#subEmail').val()
            },function (data){
                if (data === '1'){
                    alert('感谢订阅！')
                }else{
                    alert('订阅失败')
                }
            })
        }


        return false
    })
</script>